﻿#region using statements

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

#endregion

namespace NGen.Managers.GameObject
{
	/// <summary>
	/// 	<para>Base class for an object in the game engine.</para>
	/// 	<para>All objects must inherit this class in order for it to be registered in the game engine.</para>
	/// 	<para>Be sure to call the base constructor in your implementation whenever you inherit this class.</para>
	/// </summary>
	public abstract class GameObject2D : GameObject
	{
		#region local fields

		/// <summary>
		/// 	<para>The ange value of the object, in degrees, to rotate around the origin</para>
		/// 	<para>Default is 0</para>
		/// </summary>
		public double m_angle;

		/// <summary>
		/// 	<para>The origin of the object</para>
		/// 	<para>Default is (0,0) (top left corner)</para>
		/// </summary>
		public Vector2 m_origin = new Vector2(0, 0);

		/// <summary>
		/// 	<para>Position of the object on screen</para>
		/// 	<para>Default is (0,0) (top left corner)</para>
		/// </summary>
		public Vector2 m_position;

		/// <summary>
		/// 	<para>Scale the object size</para>
		/// 	<para>Can be scaled in the X and Y directions</para>
		/// 	<para>This scales both the image and the bounding box</para>
		/// 	<para>Changing the x value to 2.5 will make it scale in the by 2.5x its size</para>
		/// 	<para>Default is 1</para>
		/// </summary>
		public Vector2 m_scale = new Vector2(1, 1);

		/// <summary>
		/// 	<para>The sprite effects to use when rendering</para>
		/// 	<para>FlipHorizontal, FlipVertical, None</para>
		/// 	<para>Default is None</para>
		/// </summary>
		public SpriteEffects m_spriteEffects = SpriteEffects.None;

		/// <summary>
		/// 	<para>The image graphic representing this object</para>
		/// </summary>
		public Texture2D m_texture;

		/// <summary>
		/// 	<para>The image offset from the object origin</para>
		/// 	<para>Default is 0</para>
		/// </summary>
		public Vector2 m_textureOffset;

		/// <summary>
		/// 	<para>Color tint applied on top of the image</para>
		/// 	<para>Default is white</para>
		/// </summary>
		public Color m_textureTint = Color.White;

		/// <summary>
		/// 	<para>The Z depth of the object</para>
		/// 	<para>This determines which objects are drawn on top of others</para>
		/// 	<para>Value must be between 0 and 1</para>
		/// 	<para>Default is 0</para>
		/// </summary>
		public float m_zDepth;

		#endregion

		#region local methods

		/// <summary>
		/// 	Draw the GameObject
		/// </summary>
		/// <param name = "p_gameTime">snapshot of timing values</param>
		protected internal override void _Draw(GameTime p_gameTime) {
			if(m_texture == null) {
				return;
			}

			GameEngine.SpriteBatch.Draw(m_texture, m_position + m_textureOffset, null, m_textureTint, (float) m_angle, m_origin, m_scale, m_spriteEffects, m_zDepth);
		}

		#endregion
	}
}